import { Input } from '@/components/AntdProxy';
import Crud from '@/components/Crud';
import request from '@/utils/request';
import { useRef } from 'react';

const Index = (props) => {
  const crudRef = useRef();
  const getList = async (params) => {
    const res = await request({
      url: '/datas/pettycash/balance',
      method: 'GET',
      custom: true,
      params: params,
    });
    return {
      total: res?.total,
      data: res?.data || [],
    };
  };

  const columns = [
    {
      title: '序号',
      fixed: 'left',
      width: 65,
      render: (text, record, index) => index + 1,
    },
    {
      title: '用户名',
      dataIndex: 'username',
      width: 150,
    },
    {
      title: '金额（元）',
      dataIndex: 'balance',
      width: 150,
    },
  ];

  const fields = [
    {
      label: '用户名',
      name: 'username',
      children: <Input />,
    },
  ];

  return (
    <>
      <Crud
        ref={crudRef}
        queryFormProps={{
          labelCol: 7,
        }}
        fields={fields}
        columns={columns}
        request={getList}
      />
    </>
  );
};

export default Index;
